package prison.view;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.PopupWindow;

import com.shwread.android.qysw10000000.R;
import com.shwread.android.ui.customview.LinearListView;


public class PrisonPop extends PopupWindow {

    private View mMenuView;
    public LinearListView listView;

    public PrisonPop(Activity context ,
                     LinearListView.OnItemClickListener itemOnClick) {
        super(context);
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mMenuView = inflater.inflate(R.layout.pop_list, null);
        listView = (LinearListView) mMenuView.findViewById(R.id.listview);
        listView.setOnItemClickListener(itemOnClick);
        this.setContentView(mMenuView);
        this.setOutsideTouchable(true);
        setWidth(LinearLayout.LayoutParams.WRAP_CONTENT);
        setHeight(LinearLayout.LayoutParams.WRAP_CONTENT);
        ColorDrawable dw = new ColorDrawable(0xb0000000);
        this.setBackgroundDrawable(dw);
        this.setFocusable(true);

        getContentView().setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                // TODO Auto-generated method stub
                setFocusable(true);
                dismiss();
                return true;
            }
        });
    }
    public void setAdapter(BaseAdapter popAdapter){
        listView.setAdapter(popAdapter);
    }
}